<template>
  <div class="reportRecord">
    <!-- 搜索 -->
    <div class="search">
      <el-input placeholder="请输入内容" v-model="anchorID">
        <template slot="prepend">主播ID</template>
      </el-input>
      <el-input placeholder="请输入内容" v-model="accout">
        <template slot="prepend">举报受理号</template>
      </el-input>
      <div class="searchVal">
        <p>举报时间</p>
        <el-date-picker
          style="margin-right: 20px"
          v-model="TimeVal"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          value-format="yyyy-MM-dd"
          @change="focus"
        >
        </el-date-picker>
      </div>
      <!-- <div class="searchVal">
        <p>处罚结果</p>
        <el-select v-model="checkVal" placeholder="不限">
          <el-option label="用户违规" value="1"> </el-option>
          <el-option label="用户未违规" value="2"> </el-option>
        </el-select>
      </div> -->
      <el-button @click="search">查询</el-button>
    </div>
    <!-- 表格 -->
    <el-card>
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        v-loading="loading"
      >
        <el-table-column align="center" prop="id" label="举报受理号">
        </el-table-column>
        <el-table-column align="center" prop="reportTime" label="举报时间">
        </el-table-column>
        <el-table-column align="center" prop="userId" label="举报人ID">
        </el-table-column>
        <el-table-column align="center" prop="userName" label="举报人">
        </el-table-column>
        <el-table-column align="center" prop="reportUserId" label="举报对象ID">
        </el-table-column>
        <el-table-column align="center" prop="reportUserName" label="举报对象">
        </el-table-column>
        <el-table-column align="center" prop="banReason" label="举报类型">
        </el-table-column>
        <el-table-column align="center" prop="describes" label="举报内容">
          <template slot-scope="scope">
            <span>
              {{ scope.row.describes }}
            </span>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="picture" label="附件">
          <template slot-scope="scope">
            <el-image
              v-for="i in scope.row.picture"
              :key="i"
              class="img"
              :src="i"
              :preview-src-list="[i]"
            >
            </el-image>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="result" label="处罚结果">
          <template slot-scope="scope">
            <span>{{
              scope.row.result == "1" ? "用户未违规" : "用户违规"
            }}</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="page"
        :limit.sync="pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination"; // 分页
import { feedbackReportList } from "@/api/union";
export default {
  components: { Pagination },
  data() {
    return {
      TimeVal: "", //时间日期选择
      //   日期时间选择器数组
      pickerOptions: {
        disabledDate(platformValue) {
          return platformValue.getTime() > Date.now() - 8.64e6;
        },
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      timeStart: "", //开始时间
      timeEnd: "", //结束时间
      anchorID: "", //主播ID
      accout: "", //举报受理号
      checkVal: "", //处罚结果

      tableData: [], //表格
      loading: false,
      page: 1, //当前页
      pageSize: 10, //当前页条数
      total: 0, //总计
    };
  },
  created() {
    this.getReport();
  },
  methods: {
    //获取开始/结束时间
    focus(time) {
      if (!this.TimeVal) {
        this.TimeVal = [];
      }
      this.timeStart = this.TimeVal[0];
      this.timeEnd = this.TimeVal[1];
    },
    // 获取列表
    async getReport() {
      this.loading = true;
      let { code, data } = await feedbackReportList({
        page: this.page,
        pageSize: this.pageSize,
        userId: this.anchorID,
        sortNumber: this.accout,
        startTime: this.timeStart,
        endTime: this.timeEnd,
        type: 1,
      });
      if (code == 0) {
        console.log(data, "9527");
        this.tableData = data.list;
        this.total = parseInt(data.count);
        this.loading = false;
      }
    },
    search() {
      this.getList();
    },
    getList() {
      this.getReport();
    },
  },
};
</script>

<style lang="less" scoped>
.reportRecord {
  margin: 30px;
  height: 100%;
  .search {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 30px;
    .searchVal {
      display: flex;
      p {
        width: 80px;
        text-align: center;
        border: 1px solid #dcdfe6;
        border-right: 0px;
        height: 40px;
        line-height: 20px;
        margin: 0px;
        background: #f5f7fa;
        color: #909399;
        font-size: 14px;
        padding: 10px;
        border-radius: 4px 0px 0px 4px;
      }
    }
    /deep/.el-input {
      width: 260px;
      margin-right: 30px;
    }
    /deep/.el-button {
      margin-left: 30px;
    }
  }
}
</style>